/****************************************************************
 * Copyright (c) 2006-2007 Besture All Rights Reserved.
 * 
 * File Name:		AppSettings.cs
 * 
 * Created:		2013/06/24
 * Original Author:	Hongwei Zhao 
 * 
 * ------------------------------------------------------------
 * MODIFICATION HISTORY
 * ------------------------------------------------------------
 * When			Who		Why
 * ------------------------------------------------------------
 * 
 *
 ****************************************************************/

using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;

namespace Besture.Common.Definition
{
    /// <summary>
    /// Application setting management class.
    /// </summary>
    public class AppSettings
    {        
        ///<summary>
        /// Get page config file path
        ///</summary>
        private static string strRootPath = "";

        ///<summary>
        /// Set website root path.
        ///</summary>
        /// <param name="strRootPath">Root Path</param>
        ///<remarks></remarks>
        public static void SetRootPath(string rootPath)
        {
            strRootPath = rootPath;
        }

        ///<summary>
        /// Get page config file path
        ///</summary>
        ///<remarks></remarks>
        public static string GetPageConfigPath()
        {
            return strRootPath + ConfigurationManager.AppSettings[Constants.APP_SETTING_PAGE_CONFIG_PATH].ToString();
        }

        /// <summary>
        /// Get template path
        /// </summary>
        /// <returns></returns>
        public static string GetTemplatePath()
        {
            return strRootPath + ConfigurationManager.AppSettings[Constants.APP_SETTING_TEMPLATE_PATH].ToString();
        }

        ///<summary>
        /// Get system name
        ///</summary>
        ///<remarks></remarks>
        public static string GetSystemName()
        {
            return ConfigurationManager.AppSettings[Constants.APP_SETTING_SYSTEM_NAME].ToString();
        }

        ///<summary>
        /// Get message config file path
        ///</summary>
        ///<remarks></remarks>
        public static string GetMessagePath()
        {
            return strRootPath + ConfigurationManager.AppSettings[Constants.APP_SETTING_MESSAGE_PATH].ToString();
        }

        ///<summary>
        /// Get sql config file path
        ///</summary>
        ///<remarks></remarks>
        public static string GetSqlPath()
        {
            return strRootPath + ConfigurationManager.AppSettings[Constants.APP_SETTING_SQL_PATH].ToString();
        }

        ///<summary>
        /// Get error page path
        ///</summary>
        ///<remarks></remarks>
        public static string GetErrorPage()
        {
            return ConfigurationManager.AppSettings[Constants.APP_SETTING_ERROR_PAGE].ToString();
        }

        ///<summary>
        /// Get Excel Template Path
        ///</summary>
        ///<remarks></remarks>
        public static string GetExcelTemplatePath()
        {
            return ConfigurationManager.AppSettings[Constants.APP_SETTING_EXCEL_TEMPLATE_PATH].ToString();
        }

        ///<summary>
        /// Get Temp File Path
        ///</summary>
        ///<remarks></remarks>
        public static string GetTempFilePath()
        {
            return strRootPath +ConfigurationManager.AppSettings[Constants.APP_SETTING_TEMP_FILE_PATH].ToString();
        }

        ///<summary>
        /// Get Excel File DCSO
        ///</summary>
        ///<remarks></remarks>
        public static string GetExcelFileDCSO()
        {
            return ConfigurationManager.AppSettings[Constants.APP_SETTING_EXCEL_FILE_DCSO].ToString();
        }

        ///<summary>
        /// Get Excel File Project List
        ///</summary>
        ///<remarks></remarks>
        public static string GetExcelFilePrjList()
        {
            return ConfigurationManager.AppSettings[Constants.APP_SETTING_EXCEL_FILE_PRJ_LIST].ToString();
        }

        ///<summary>
        /// Get Excel File Project List All Out Flg
        ///</summary>
        ///<remarks></remarks>
        public static bool GetExcelFilePrjListAllOutFlg()
        {
            return bool.Parse(ConfigurationManager.AppSettings[Constants.APP_SETTING_EXCEL_FILE_PRJ_LIST_ALL_OUT_FLG].ToString());
        }

        ///<summary>
        /// Get SMTP Server
        ///</summary>
        ///<remarks></remarks>
        public static string GetSMTPServer()
        {
            return ConfigurationManager.AppSettings[Constants.APP_SETTING_SMTP_SERVER].ToString();
        }

        ///<summary>
        /// Get SMTP port
        ///</summary>
        ///<remarks></remarks>
        public static int GetSMTPPort()
        {
            return Int32.Parse(ConfigurationManager.AppSettings[Constants.APP_SETTING_SMTP_PORT].ToString());
        }

        ///<summary>
        /// Get default From mail address
        ///</summary>
        ///<remarks></remarks>
        public static string GetDefaultFromMailAddress()
        {
            return ConfigurationManager.AppSettings[Constants.APP_SETTING_DEFAULT_FROM_MAIL_ADDRESS].ToString();
        }

        ///<summary>
        /// Get default From mail password
        ///</summary>
        ///<remarks></remarks>
        public static string GetDefaultFromMailPassword()
        {
            return ConfigurationManager.AppSettings[Constants.APP_SETTING_DEFAULT_FROM_MAIL_PASSWORD].ToString();
        }

        /// <summary>
        /// Get LogSwitch state
        /// </summary>
        /// <returns></returns>
        public static string GetLogSwitch()
        {
            return ConfigurationManager.AppSettings[Constants.APP_SETTING_LOG_SWITCH].ToString().ToLower();
        }
    }
}
